#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int n, m;
int s[N][N], l[N], r[N];
int q[N];
int work(int h[]) {
  h[0] = h[m + 1] = -1;
  int tt = 0;
  q[0] = 0;
  for (int i = 1; i <= m; ++i) {
    while (h[q[tt]] >= h[i]) tt--;
    l[i] = q[tt];
    q[++tt] = i;
  }

  tt = 0;
  q[0] = m + 1;
  for (int i = m; i; i--) {
    while (h[q[tt]] >= h[i]) tt--;
    r[i] = q[tt];
    q[++tt] = i;
  }

  int res = 0;
  for (int i = 1; i <= m; ++i) res = max(res, h[i] * (r[i] - l[i] - 1));

  return res;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      char c;
      cin >> c;
      if (c == 'F') s[i][j] = s[i - 1][j] + 1;
    }
  int res = 0;
  for (int i = 1; i <= n; ++i) res = max(res, work(s[i]));

  cout << res * 3 << endl;
}
